package com.cw.subject.infra.basic.service.impl;

import com.cw.subject.infra.basic.entity.SubjectMappingPO;
import com.cw.subject.infra.basic.mapper.SubjectMappingPODao;
import com.cw.subject.infra.basic.service.SubjectMappingPOService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 题目分类关系表(SubjectMappingPO)表服务实现类
 *
 * @author makejava
 * @since 2024-04-10 18:54:04
 */
@Service("subjectMappingService")
public class SubjectMappingPOServiceImpl implements SubjectMappingPOService {
    @Resource
    private SubjectMappingPODao subjectMappingPODao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SubjectMappingPO queryById(Integer id) {
        return this.subjectMappingPODao.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param subjectMappingPO 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectMappingPO insert(SubjectMappingPO subjectMappingPO) {
        this.subjectMappingPODao.insert(subjectMappingPO);
        return subjectMappingPO;
    }

    /**
     * 修改数据
     *
     * @param subjectMappingPO 实例对象
     * @return 实例对象
     */
    @Override
    public int update(SubjectMappingPO subjectMappingPO) {
        return this.subjectMappingPODao.update(subjectMappingPO);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.subjectMappingPODao.deleteById(id) > 0;
    }

    /**
     * 通过标签id查询
     */
    @Override
    public List<SubjectMappingPO> queryLabelId(SubjectMappingPO subjectMappingPO) {
        return this.subjectMappingPODao.queryDistinctLabelId(subjectMappingPO);
    }

    /**
     * 批量插入数据
     */
    @Override
    public void batchInsert(List<SubjectMappingPO> mappingList) {
        this.subjectMappingPODao.insertBatch(mappingList);
    }
}
